﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IDAL;
using DAL;
using Models;

namespace BLL
{
    public class WorksCategoryInfoLogic
    {
        public static IWorksCategoryInfo workscategory = new WorksCategoryInfoDAL();

        public static List<WorksCategoryInfo> GetAllWorksCategoryInfo()
        {
            return GetAllWorksCategoryInfo(0);
        }

        public static List<WorksCategoryInfo> GetAllWorksCategoryInfo(int CategoryID)
        {
            List<WorksCategoryInfo> list = new List<WorksCategoryInfo>();
            list = workscategory.GetAllWorksCategoryInfo();
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].CategoryID == CategoryID)
                {
                    list[i].NowPlace = "nowcf";
                    list[i].CurrentFlag = "current";
                }
                else
                {
                    list[i].NowPlace = "";
                    list[i].CurrentFlag = "";
                }
                if (list[i].HasNWork == 1)
                {
                    list[i].CategoryNew = "<div class='ncflag'></div>";
                }
                else
                {
                    list[i].CategoryNew = "";
                }
            }
            return list;
        }

        public static int GetPageCount(int pagesize)
        {
            return workscategory.GetPageCount(pagesize);
        }

        public static List<WorksCategoryInfo> GetNowPageWorksCategoryInfo(int pagesize, int nowpage)
        {
            List<WorksCategoryInfo> list = new List<WorksCategoryInfo>();
            list = workscategory.GetNowPageWorksCategoryInfo(pagesize, nowpage);
            return list;
        }

        public static WorksCategoryInfo GetOneWorksInfo(int CategoryID)
        {
            return workscategory.GetOneWorksCategory(CategoryID);
        }
        public static int DeleteWorksCategoryInfo(int CategoryID)
        {
            return workscategory.DeleteWorksCategoryInfo(CategoryID);
        }
        public static int UpdateWorksCategoryInfo(WorksCategoryInfo wc)
        {
            return workscategory.UpdateWorksCategoryInfo(wc);
        }
        public static int AddWorksCategoryInfo(WorksCategoryInfo wc)
        {
            return workscategory.AddWorksCategoryInfo(wc);
        }
        public static List<WorksCategoryInfo> GetAdminWorksCategory()
        {
            return workscategory.GetAdminWorksCategory();
        }
    }

}
